<template>
  <div id="proportion-rings">
    <div id="proportion-rings-title">
      <div class="proportion-rings-title">
        <img src="static/img/yellow-con.png" class="proportion-rings-img1">
        <img src="static/img/yellow-con.png" class="proportion-rings-img2">
        <img src="static/img/yellow-con.png" class="proportion-rings-img3">
        <img src="static/img/yellow-con.png" class="proportion-rings-img4">
        <img src="static/img/yellow-con.png" class="proportion-rings-img5">
        <img src="static/img/yellow-con.png" class="proportion-rings-img6">
        <img src="static/img/yellow-con.png" class="proportion-rings-img7">
        <img src="static/img/yellow-con.png" class="proportion-rings-img8">
        <img src="static/img/blue-con.png" class="proportion-rings-img9">
        <img src="static/img/blue-con.png" class="proportion-rings-img10">
        <img src="static/img/blue-con.png" class="proportion-rings-img11">
        <img src="static/img/blue-con.png" class="proportion-rings-img12">
        <span>活跃车非活跃车占比</span>
      </div>
    </div>
    <div class="num">{{active + inactive}}</div>
    <div class="num1">总车辆数(辆)</div>
    <div class="rings-botton">
      <div id="proportion-rings-chart"></div>
      <!--<div class="num-class">-->
        <div class="active-car">
          <div class="active-title">活跃车辆(辆)</div>
          <div class="active-num">{{active}}</div>
          <div class="active-per">{{activeper}}</div>
          <div class="active-per1">%</div>
        </div>
        <div class="inactive-car">
          <div class="inactive-title">非活跃车辆(辆)</div>
          <div class="inactive-num">{{inactive}}</div>
          <div class="inactive-per">{{inactiveper}}</div>
          <div class="inactive-per1">%</div>
        </div>
      <!--</div>-->

    </div>
  </div>
</template>

<script>
  export default {
    name: 'proportion-rings',
    data() {
      return {
        message : 'Welcome to Your Vue.js App',
        active : 500,
        inactive : 600,
        activeper : 10,
        inactiveper : 20,
        timeList : 1513645200000
      }
    },
    mounted() {
      this.drawRings();
    },
    methods: {
      drawRings: function () {
        let ringsChart = echarts.init(document.getElementById('proportion-rings-chart'));
        ringsChart.setOption({
          color: ['rgba(0, 158, 158, 0.2)','rgba(32,221,201,0.80)'],
//          backgroundColor: 'rgba(7,34,31,0.80)',
          title: {},
          tooltip: {},
          series: [
            {
              name:'访问来源',
              type:'pie',
              radius: ['50%', '70%'],
              avoidLabelOverlap: false,
              label: {
                normal: {
                  show: false,
                  position: 'center'
                },
                emphasis: {
                  show: true,
                  textStyle: {
                    fontSize: '30',
                    fontWeight: 'bold'
                  }
                }
              },
              labelLine: {
                normal: {
                  show: false
                }
              },
              data:[]
            }
          ]
        });
        var active = [];
        var inactive = [];
//        const allactives =active.concat(inactive);

        $.ajax({
          type : 'get',
          async : true,
          url: 'http://203.81.245.37:2420/platformservice/right/' +this.timeList ,
          data :{},
          dataType : 'json',
          success :  (result) => {
            if (result) {
              let result_caractive = result.caractive;
//              console.log(result_caractive.active);
              for (var j=0;j<result_caractive.length;j++) {
                active.push(result_caractive[j].active)
              }
              for (var j=0;j<result_caractive.length;j++) {
                inactive.push(result_caractive[j].inactive)
              }
              this.active = result_caractive.active;
              this.inactive = result_caractive.inactive;
              var ainctive = this.active + this.inactive;
              this.activeper = (this.active/ainctive).toFixed(3)*100;
              this.inactiveper = (this.inactive/ainctive).toFixed(3)*100;
//              this.active = active[0];
//              this.inactive = inactive[0];
//              console.log(active);
              var allActives = [result_caractive.active,result_caractive.inactive];
//              allActives = active.concat(inactive);
//              console.log(allActives);
              ringsChart.setOption({
                series: [{
                  data:allActives
                }]
              })
            }
          }
        })

      }
    }
  }
</script>

<style>
  #proportion-rings {
    height: 260px;
    width: 440px;
    position: relative;
  }
  #proportion-rings-title {
    height: 40px;
    width: 438px;
    background: rgba(7, 34, 31, 0.8);
    border-width: 1px;
    border-style: solid;
    border-color: rgba(32, 221, 201, 0.8);
    border-image: initial;
  }
  .proportion-rings-title {
    height: 30px;
    width: 428px;
    position: absolute;
    top: 6px;
    left: 6px;
    font-family: MicrosoftYaHeiUI;
    text-align: left;
    text-indent: 4px;
    font-size: 18px;
    line-height: 30px;
    color: rgb(239, 187, 66);
    letter-spacing: -0.45px;
    background: rgba(0, 158, 158, 0.2);
  }
  #proportion-rings-chart {
    height: 217px;
    width: 220px;
    /*background: rgba(7,34,31,0.80);*/
    /*border: 1px solid rgba(32,221,201,0.80);*/
  }
  .num {
    position: absolute;
    z-index: 100;
    top: 133px;
    left: 90px;
    color: #FFFFFF;
  }
  .num1 {
    position: absolute;
    z-index: 100;
    top: 156px;
    left: 66px;
    color: rgb(239, 187, 66);
  }
  .num-class {
    position: absolute;
    right: 10px;
    top: 100px;
  }
  .rings-botton {
    position: absolute;
    /*background: #FFC0CB;*/
    width: 438px;
    background: rgba(7,34,31,0.80);
    border: 1px solid rgba(32,221,201,0.80);
  }
  .active-car {
    position: absolute;
    right: 130px;
    top: 50px;
    color: #fff;
  }
  .active-title {
    height: 15px;
    width: 66px;
    font-family: MicrosoftYaHeiUI;
    font-size: 12px;
    color: #EFBB42;
    letter-spacing: -0.3px;
  }
  .active-num {
    height: 34px;
    width: 66px;
    color: #7AE9E5;

  }
  .active-per {
    /*height: 34px;*/
    /*width: 66px;*/
    /*color: rgba(32,221,201,0.80);*/
    position: absolute;
    left: 87px;
    top: -6px;
    font-family: MicrosoftYaHeiUI-Bold;
    font-size: 36px;
    color: #7AE9E5;
    letter-spacing: -0.9px;
    line-height: 46px;
  }
  .active-per1 {
    /*height: 34px;*/
    /*width: 66px;*/
    color: #7AE9E5;
    position: absolute;
    left: 160px;
    top: 16px;
  }
  .inactive-car {
    position: absolute;
    right: 120px;
    top: 150px;
    color: #fff;
  }
  .inactive-title {
    height: 15px;
    width: 78px;
    font-family: MicrosoftYaHeiUI;
    font-size: 12px;
    color: #EFBB42;
    letter-spacing: -0.3px;
  }
  .active-num {
    height: 34px;
    width: 66px;
    /*color: #7AE9E5;*/
    font-family: MicrosoftYaHeiUI-Bold;
    font-size: 24px;
    color: #7AE9E5;
    letter-spacing: -0.6px;
    line-height: 34px;
  }

  .inactive-per {
    /*height: 34px;*/
    /*width: 66px;*/
    font-family: MicrosoftYaHeiUI-Bold;
    font-size: 36px;
    color: #2AA19D;
    letter-spacing: -0.9px;
    line-height: 46px;
    position: absolute;
    left: 87px;
    top: -6px;
  }
  .inactive-per1 {
    /*height: 34px;*/
    /*width: 66px;*/
    color: #2AA19D;
    position: absolute;
    left: 160px;
    top: 16px;
  }
  .proportion-rings-img1 {
    position: absolute;
    top: -7px;
    left: -7px;
    z-index: 3;
  }
  .proportion-rings-img2 {
    position: absolute;
    top: -7px;
    left: 429px;
    transform: rotate(90deg);
    z-index: 3;
  }
  .proportion-rings-img3 {
    position: absolute;
    top: 32px;
    left: 429px;
    transform: rotate(180deg);
    z-index: 3;
  }
  .proportion-rings-img4 {
    position: absolute;
    top: 32px;
    left: -7px;
    transform: rotate(270deg);
    z-index: 3;
  }
  .proportion-rings-img5 {
    position: absolute;
    top: 35px;
    left: -7px;
    z-index: 3;
  }
  .proportion-rings-img6 {
    position: absolute;
    top: 35px;
    left: 429px;
    transform: rotate(90deg);
    z-index: 3;
  }
  .proportion-rings-img7 {
    position: absolute;
    top: 250px;
    left: 429px;
    transform: rotate(180deg);
    z-index: 3;
  }
  .proportion-rings-img8 {
    position: absolute;
    top: 250px;
    left: -7px;
    transform: rotate(270deg);
    z-index: 3;
  }
  .proportion-rings-img9 {
    position: absolute;
    top: -1px;
    left: -1px;
    z-index: 3;
  }
  .proportion-rings-img10 {
    position: absolute;
    top: -1px;
    left: 425px;
    transform: rotate(90deg);
    z-index: 3;
  }
  .proportion-rings-img11 {
    position: absolute;
    top: 27px;
    left: 425px;
    transform: rotate(180deg);
    z-index: 3;
  }
  .proportion-rings-img12 {
    position: absolute;
    top: 27px;
    left: -1px;
    transform: rotate(270deg);
    z-index: 3;
  }
</style>
